class Snake {
    // 蛇头
    head: HTMLElement
    // 身体
    bodies: HTMLCollection;
    // 容器
    element: HTMLElement;

    constructor() {
        this.element = document.getElementById("snake")!;
        this.head = document.querySelector("#snake>div")! as HTMLElement;
        this.bodies = document.getElementById("snake")!.getElementsByTagName("div");
    }

    get X() {
        return this.head.offsetLeft;
    }

    get Y() {
        return this.head.offsetTop;
    }

    set X(value:number){
        this.head.style.left = value+"px";
    }

    set Y(value:number){
        this.head.style.top =  value+"px";
    }

    addBody(){
        this.element.insertAdjacentHTML("beforeend","<div></div>")
    }

}

export default Snake;